package com.emm.yixun.mobile.ui.customer;

import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Contacts.Data;
import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.adapter.FollowUpAdapter;
import com.emm.yixun.mobile.adapter.FoucsAdapter;
import com.emm.yixun.mobile.adapter.HousingAdapter;
import com.emm.yixun.mobile.adapter.MultiInterfaceAdapter;
import com.emm.yixun.mobile.application.EmmApplication;
import com.emm.yixun.mobile.base.BaseActivity;
import com.emm.yixun.mobile.model.DistributionConsultant;
import com.emm.yixun.mobile.model.GetConsultantList;
import com.emm.yixun.mobile.model.GetConsultantList.ConsultantList;
import com.emm.yixun.mobile.model.GetCustomerDetail;
import com.emm.yixun.mobile.model.GetCustomerDetail.FamilyMemberList;
import com.emm.yixun.mobile.model.GetDictionaryList.RqBusNumList;
import com.emm.yixun.mobile.model.GetFollowList;
import com.emm.yixun.mobile.model.GetHouseTypeList;
import com.emm.yixun.mobile.model.GetPremisesList.PremisesList;
import com.emm.yixun.mobile.model.GetRoomList.RoomList;
import com.emm.yixun.mobile.model.GetTagListBean;
import com.emm.yixun.mobile.ui.FromListActivity;
import com.emm.yixun.mobile.ui.from.NewFromActivity;
import com.eroad.product.tools.MyListView;
import com.eroad.product.tools.PickerView;
import com.eroad.product.tools.PickerView.onSelectListener;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.functions.Consumer;
import me.imid.swipebacklayout.lib.SwipeBackLayout;
import me.imid.swipebacklayout.lib.app.SwipeBackActivity;
import xf.tools.Loading;

import static android.Manifest.permission.GET_ACCOUNTS;
import static android.Manifest.permission.READ_CONTACTS;
import static android.Manifest.permission.WRITE_CONTACTS;

/**
 * <p>
 * <b>Title：</b> 客户详情
 * </p>
 * <p>
 * <b>Description：</b>
 * </p>
 *
 * @author tangxin
 * @date 2016年12月6日 下午4:07:06
 */
public class CustomerDetailActivity extends SwipeBackActivity {

    private static final String TAG = "CustomerDetailActivity";

    /**
     * 客户个人信息
     */
    private boolean IsUserl = true;

    /**
     * 需求信息是否展开标识
     */
    private boolean IsOpen = true;

    /**
     * 跟进是否展开标识
     */
    private boolean IsGenjin = true;

    /**
     * 更多模块标识
     */
    private boolean IsOpenmore = true;

    /**
     * 首次接触信息标识
     */
    private boolean FirtOpen = true;

    /**
     * 客户个人信息标识
     */
    private boolean UserPersonalOpen = true;

    /**
     * 客户标签标识
     */
    private boolean flagCustomer = true;

    /**
     * 家庭情况标识
     */
//    private boolean HomeType = true;

    /**
     * 家庭住宅情况标识
     */
//    private boolean HomehouseOpen = true;

    /**
     * 联系信息标识
     */
//    private boolean TimePhoneOpen = true;

    /**
     * 需求信息
     */
    LinearLayout open_or_close;

    /**
     * 需求信息模块
     */
    LinearLayout cosut_all;

    /**
     * 客户标签
     */
    LinearLayout lvFlag;

    MyListView ltvMoreCustomer;

    LinearLayout lvMoreCustomerFlag;

    /**
     * 展开或收起箭头图标
     */
    ImageView rl1, rl2, rl3, rl4, rl5, rl6, rl7, rl8, ivFlag;

    /**
     * 更多
     */
    TextView more_btn;

    /**
     * 更多模块
     */
    LinearLayout more_layout;

    /**
     * 首次接触信息
     */
    LinearLayout firstopen_btn;

    /**
     * 首次接触信息模块
     */
    LinearLayout first_layout;

    /**
     * 客户个人信息
     */
    LinearLayout user_personal;

    /**
     * 客户个人信息模块
     */
    LinearLayout user_personal_layout;

    /**
     * 家庭情况
     */
//    LinearLayout hometype_btn;

    /**
     * 家庭情况模块
     */
//    LinearLayout hometype_layout;

    /**
     * 家庭住宅情况
     */
//    LinearLayout homehouse_btn;

    /**
     * 家庭住宅情况模块
     */
//    LinearLayout homehouse_layout;

    /**
     * 联系情况
     */
//    LinearLayout timephoneopen_btn;

    /**
     * 联系情况
     */
//    LinearLayout timephoneopen_layout;

    /**
     * 家庭成员listview
     */
//    MyListView home_list;

    /**
     * 家庭成员数据源
     */
//    ArrayList<BirtchdayModel> bl;

    /**
     * 家庭成员适配器
     */
//    BirtchdayAdapter adapter;

    /**
     * 家庭成员添加按钮
     */
//    ImageView addview;

    /**
     * 保存按钮
     */
    TextView shuerbtn;

    /**
     * title
     */
    TextView title_main;

    /**
     * 返回按钮
     */
    ImageView back_btn;

    /**
     * 性别
     */
    TextView set_sex;

    List<String> listname;

    /**
     * 意向等级
     */
    TextView set_dj;

    /**
     * 客户来源
     */
//    TextView set_bean;

    /**
     * 客户状态
     */
//    TextView set_bf;

    /**
     * 首次接触信息
     */
    TextView first_do;

    /**
     * 首次接触时间
     */
    TextView first_time;

    /**
     * 选择时间显示view
     */
//    TextView time_ed;

    /**
     * 选择地址显示view
     */
//    TextView addr_ed;

    /**
     * 证件类型
     */
//    TextView set_papers;

    /**
     * 生日
     */
//    TextView set_birtch;

    /**
     * 学历
     */
//    TextView set_xm;

    /**
     * 户籍所在地
     */
//    TextView set_addr;

    /**
     * 居住区
     */
    TextView set_none1;

    /**
     * 工作区
     */
    TextView set_works;

    /**
     * 车架品牌
     */
//    TextView set_cardtype;

    /**
     * 家庭年收入
     */
//    TextView set_priceget;

    /** 兴趣爱好 */
    // TextView set_intersting;

    /** 乐于参加的活动类型 */
    // TextView set_happy;

    /**
     * 结婚纪念日
     */
//    TextView set_mr;

    /**
     * 目前居住的物业类型
     */
//    TextView set_htype;

    /**
     * 目前居住面积
     */
//    TextView set_m2s;

    /**
     * 目前居住的物业结构
     */
//    TextView set_htype1;

    /**
     * 目前居住/办公的房子属性
     */
//    TextView set_hstacut;

    /**
     * 工作联系时间
     */
//    TextView set_worktime;

    /**
     * 工作联系方式
     */
//    TextView set_workltype;

    /**
     * 周末联系时间
     */
//    TextView set_weektime;

    /**
     * 周末联系方式
     */
//    TextView set_weektype;

    /**
     * 置业动机
     */
    TextView set_incentive;

    /**
     * 关注重点
     */
    TextView set_drop;

    /**
     * 关注户型
     */
//    TextView set_hrdop;

    /**
     * 需求面积
     */
    TextView set_m2_1;

    /**
     * 预算总价
     */
//    TextView set_none_allprice;

    /**
     * 预算单价
     */
//    TextView set_unit;

    /**
     * 付款方式
     */
//    TextView set_paytype;

    /**
     * 意向组团
     */
//    TextView set_wantdeam;

    /**
     * 需求楼层
     */
//    TextView set_lnumber;

    /**
     * 意向房源
     */
    TextView set_wantbean;

    /** 生活配套 */
    // TextView set_td;

    /**
     * 生活服务
     */
    TextView set_td2;

    /**
     * 希望庭院具备的配置
     */
//    TextView set_wantpz;

    /**
     * 关注重点
     */
    MyListView focuss_list;

    /**
     * 关注重点适配器
     */
    FoucsAdapter foucsAdapter;

    /**
     * 关注户型list
     */
//    MyListView atten_list;

    /**
     * 关注户型适配器
     */
//    AttentionAdapter attadapter;

    /**
     * 意向组团
     */
//    MyListView group_list;

    /**
     * 意向组团适配器
     */
//    GroupAdapter gpadapter;

    /**
     * 意向房源
     */
    MyListView want_list;

    /**
     * 意向房源横线
     */
    View want_list_lines;

    /**
     * 意向房源适配器
     */
    HousingAdapter hgadapter;

    /**
     * 客户信息
     */
    LinearLayout user_linean1;

    /**
     * 客户个人信息模块
     */
    LinearLayout user_layout;

    /**
     * 电话
     */
    TextView phone_tel;

    /**
     * 打电话
     */
//    LinearLayout call_tel;

    /**
     * 发短信
     */
//    LinearLayout sms;

    /**
     * 编辑
     */
    LinearLayout update_lieanr;

    /**
     * 写跟进
     */
    LinearLayout wt_linear;

    /**
     * 菜单按钮
     */
    ImageView more_btn_include;

    /**
     * 姓名
     */
    TextView user_name;

    /**
     * 指派
     */
    View viewzp;

    /**
     * 指派
     */
    PopupWindow popuzp;

    /**
     * 指派选择框选中的置业顾问
     */
    private String selectName;

    /**
     * 指派选择框选中的置业顾问 的下标
     */
    private int SelectID;

    /**
     * 认筹
     */
    RelativeLayout fromlist;

    /**
     * 认购
     */
    RelativeLayout sure_pay;

    /**
     * 签约
     */
    RelativeLayout bt_over;

    /**
     * 资料完善度
     */
    SeekBar customer_seekbar;

    /**
     * 跟进记录list
     */
    MyListView genjin_list;

    /**
     * 跟进记录适配器
     */
    FollowUpAdapter genjinadapter;

    /**
     * 跟进布局
     */
    LinearLayout genjin_layout;

    /**
     * 客户详情
     */
    GetCustomerDetail details;

    /**
     * 客户ID
     */
    String customerId;

    /**
     * 资料完善度百分
     */
    TextView integrity_view;

    /**
     * 星标
     */
    TextView user_star;

    /**
     * 性别
     */
    TextView user_sex;

    /**
     * 评分等级
     */
    TextView user_number;

    /**
     * 客户状态
     */
    TextView customerStatus_view;

    /**
     * 客户来源
     */
    TextView customerOrigin_view;

    /**
     * 认筹数
     */
    TextView count1;

    /**
     * 认购数
     */
    TextView count2;

    /**
     * 签约数
     */
    TextView count3;

    /**
     * 庭院需求面积
     */
//    TextView rqCourtyardArea_view;

    /**
     * 庭院需求面积单位 m2
     */
//    TextView unit_area;

    /**
     * 备注
     */
//    TextView remark_view;

    /**
     * 沟通内容
     */
    TextView ftContactContent;

    /**
     * 证件号码
     */
//    TextView peDocumentNumber;

    /**
     * 年龄
     */
//    TextView peAge;

    /**
     * 固话
     */
//    TextView peTelephone_view;

    /**
     * 手机
     */
//    TextView peMobile;

    /**
     * 微信
     */
//    TextView peWechat_view;

    /**
     * 邮箱
     */
//    TextView peEmail;

    /**
     * 邮编
     */
//    TextView pePostcode;

    /**
     * 联系地址
     */
//    TextView peContactAddress;

    /**
     * 小区
     */
    TextView pePlot_view;

    /**
     * 详细 地址（小区）
     */
    TextView peDetailedAddress;

    /**
     * 详细地址(工作)
     */
    TextView peWorkaroundAddress_view;

    /**
     * 本地购房次数
     */
//    TextView reLocalPurchase;

    /**
     * 目前家庭拥有住宅数
     */
//    TextView reCurrentHoldings;

    /**
     * 目前家庭拥有住宅已按揭数
     */
//    TextView reResidentialMortgage;

    /**
     * 播放录音布局
     */
    RelativeLayout play_video;

    /**
     * 关闭按钮
     */
    ImageView close_btn;

    /**
     * 播放提示view
     */
    TextView tson_textcontent;

    /**
     * 播放效果
     */
    ImageView image_icon;

    /**
     * 权限展示
     */
    LinearLayout type_lk;

    /**
     * 电话父类布局
     */
    LinearLayout CallPhone_1;

    /**
     * 多套标识
     */
    ImageView duotao_image;

    /**
     * 获知途径
     */
    TextView get_type_persong;

    /**
     * 获知途径模块
     */
    LinearLayout is_selecet_all;

    /**
     * 推荐人类别
     */
    TextView recommendedCategory_view;

    /**
     * 推荐人姓名
     */
    TextView recommendedName_view;

    /**
     * 推荐人手机
     */
    TextView recommendedMobile_view;

    /**
     * 推荐人单位
     */
    TextView recommendedUnit_view;

    /**
     * 意向房源类型
     */
    TextView intentionPropertyType;

    /** 意向物业类型 */
    // TextView dailyInformation;

    /**
     * 购买车位
     */
//    TextView buyParking;

    /**
     * 创建人
     */
    TextView createUserName;

    /**
     * 归属人
     */
    TextView attributionName;

    /**
     * 意向房源更多
     */
    LinearLayout more_linearlayout;

    /**
     * 意向房源更多标题
     */
    TextView more_title;

    /**
     * 意向房源更多图标
     */
    ImageView more_icon;

    /**
     * 侧滑关闭框架
     */
    private SwipeBackLayout mSwipeBackLayout;

    /**
     * QQ号
     */
//    TextView qqnum;

    /**
     * 从事行业
     */
//    TextView industry;

    /**
     * 公司性质
     */
//    TextView natureCompany;

    /**
     * 公司年营业额
     */
//    TextView annualTurnoverCompany;

    /**
     * 家庭结构
     */
//    TextView familyStructure;

    /**
     * 是否员工
     */
//    TextView isEmployees;

    /**
     * 是否本公司业主
     */
//    TextView isOwnerCompany;

    /**
     * 是否与老人同住
     */
//    TextView isLiveElderly;

    /**
     * 是否有子女
     */
//    TextView isChildren;

    /**
     * 选择列表适配器 生活服务
     */
    MultiInterfaceAdapter LifeServiceadapter1;
    /**
     * 选择列表适配器 生活配套
     */
//    MultiInterfaceAdapter SupportingLifeaceadapter2;
    /**
     * 选择列表适配器 乐于参加的活动类型
     */
//    MultiInterfaceAdapter ATypeOfActivityThatIsWillingToParticipateaceadapter3;
    /**
     * 选择列表适配器 兴趣爱好
     */
//    MultiInterfaceAdapter HobbyListaceadapter4;
    /**
     * 选择列表适配器 日常信息获知途径
     */
//    MultiInterfaceAdapter DailyInformationLearningApproachaceadapter5;

    /**
     * 选择列表 生活服务
     */
//    MyListView LifeService_list;
    /**
     * 选择列表 生活配套
     */
//    MyListView SupportingLife_list;
    /**
     * 选择列表 乐于参加的活动类型
     */
//    MyListView ATypeOfActivityThatIsWillingToParticipate_list;
    /**
     * 选择列表 兴趣爱好
     */
//    MyListView HobbyList_list;
    /**
     * 选择列表 日常信息获知途径
     */
//    MyListView DailyInformationLearningApproach_list;

    private LinearLayout lvIntentionLevel;

    private TextView tvIntentionLevelRemark;

    private View vIntentionLv;

    //问卷调查
    LinearLayout lvInvestigation;

    boolean isInvestigation;

    //图标
    ImageView ivInvestigation;

    MyListView ltvInvestigation;

    LinearLayout lvInvestigationRoot;

    InvestigationAdapter investigationAdapter;

    TagListAdapter tagListAdapter;

    LinearLayout llFirstContact, llFirstContact1;
    TextView tvFirstContactWay, tvFirstContacyTime, tvFirstContactContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        System.out.println("Customer->onCreate");
        setContentView(R.layout.customer_datail_activity);
        SetSwipeBackLayout(mSwipeBackLayout);
        BaseActivity.activity = this;
        customerId = getIntent().getStringExtra("customerId");
        Log.v(TAG, "customerId:->" + customerId);
        initView();
        initView2();
        SetRelativiLayoutPadding(R.id.main_head_top_rela);
        initBtn();
        getFollowList(customerId);
    }

    /**
     * <p>
     * <b>Title：</b> 初始化view
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午1:59:49
     */
    private void initView() {
        llFirstContact = (LinearLayout) findViewById(R.id.ll_first_contact);
        llFirstContact1 = (LinearLayout) findViewById(R.id.ll_first_contact1);
        tvFirstContactWay = (TextView) findViewById(R.id.tv_first_contact_way);
        tvFirstContacyTime = (TextView) findViewById(R.id.tv_first_contact_time);
        tvFirstContactContent = (TextView) findViewById(R.id.tv_first_contact_content);
        open_or_close = (LinearLayout) findViewById(R.id.open_or_close);
        cosut_all = (LinearLayout) findViewById(R.id.cosut_all);
        rl1 = (ImageView) findViewById(R.id.rl1);
        more_btn = (TextView) findViewById(R.id.more_btn_t);
        more_layout = (LinearLayout) findViewById(R.id.more_layout);
        firstopen_btn = (LinearLayout) findViewById(R.id.firstopen);
        first_layout = (LinearLayout) findViewById(R.id.first_layout);
        rl2 = (ImageView) findViewById(R.id.rl2);
        user_personal = (LinearLayout) findViewById(R.id.user_personal);
        user_personal_layout = (LinearLayout) findViewById(R.id.user_personal_layout);
        rl3 = (ImageView) findViewById(R.id.rl3);
//        hometype_btn = (LinearLayout) findViewById(R.id.hometype_btn);
//        hometype_layout = (LinearLayout) findViewById(R.id.hometype_layout);
        rl4 = (ImageView) findViewById(R.id.rl4);
//        homehouse_btn = (LinearLayout) findViewById(R.id.homehouse_btn);
//        homehouse_layout = (LinearLayout) findViewById(R.id.homehouse_layout);
        rl5 = (ImageView) findViewById(R.id.rl5);
//        timephoneopen_btn = (LinearLayout) findViewById(R.id.timephoneopen_btn);
//        timephoneopen_layout = (LinearLayout) findViewById(R.id.timephoneopen_layout);
        rl6 = (ImageView) findViewById(R.id.rl6);
//        home_list = (MyListView) findViewById(R.id.home_list);
        shuerbtn = (TextView) findViewById(R.id.shuerbtn);
//        addview = (ImageView) findViewById(R.id.addview);
        title_main = (TextView) findViewById(R.id.title_main);
        title_main.setText(getString(R.string.details_cosutmoer));
        back_btn = (ImageView) findViewById(R.id.back_btn);
        set_sex = (TextView) findViewById(R.id.set_sex);
        set_dj = (TextView) findViewById(R.id.set_dj);
//        set_bean = (TextView) findViewById(R.id.set_bean);
//        set_bf = (TextView) findViewById(R.id.set_bf);
        first_do = (TextView) findViewById(R.id.first_do);
        first_time = (TextView) findViewById(R.id.first_time);
//        set_papers = (TextView) findViewById(R.id.set_papers);
//        set_birtch = (TextView) findViewById(R.id.set_birtch);
//        set_xm = (TextView) findViewById(R.id.set_xm);
//        set_addr = (TextView) findViewById(R.id.set_addr);
        set_none1 = (TextView) findViewById(R.id.set_none1);
        set_works = (TextView) findViewById(R.id.set_works);
//        set_cardtype = (TextView) findViewById(R.id.set_cardtype);
//        set_priceget = (TextView) findViewById(R.id.set_priceget);
        // set_intersting = (TextView) findViewById(R.id.set_intersting);
        // set_happy = (TextView) findViewById(R.id.set_happy);
//        set_mr = (TextView) findViewById(R.id.set_mr);
//        set_htype = (TextView) findViewById(R.id.set_htype);
//        set_m2s = (TextView) findViewById(R.id.set_m2s);
//        set_htype1 = (TextView) findViewById(R.id.set_htype1);
//        set_hstacut = (TextView) findViewById(R.id.set_hstacut);
//        set_worktime = (TextView) findViewById(R.id.set_worktime);
//        set_workltype = (TextView) findViewById(R.id.set_workltype);
//        set_weektime = (TextView) findViewById(R.id.set_weektime);
//        set_weektype = (TextView) findViewById(R.id.set_weektype);
        set_incentive = (TextView) findViewById(R.id.set_incentive);
        set_drop = (TextView) findViewById(R.id.set_drop);
//        set_hrdop = (TextView) findViewById(R.id.set_hrdop);
        set_m2_1 = (TextView) findViewById(R.id.set_m2_1);
//        set_none_allprice = (TextView) findViewById(R.id.set_none_allprice);
//        set_unit = (TextView) findViewById(R.id.set_unit);
//        set_paytype = (TextView) findViewById(R.id.set_paytype);
//        set_wantdeam = (TextView) findViewById(R.id.set_wantdeam);
//        set_lnumber = (TextView) findViewById(R.id.set_lnumber);
        set_wantbean = (TextView) findViewById(R.id.set_wantbean);
        // set_td = (TextView) findViewById(R.id.set_td);
        // set_td2 = (TextView) findViewById(R.id.set_td2);
//        set_wantpz = (TextView) findViewById(R.id.set_wantpz);
        focuss_list = (MyListView) findViewById(R.id.focuss_list);
//        atten_list = (MyListView) findViewById(R.id.atten_list);
//        group_list = (MyListView) findViewById(R.id.group_list);
        want_list = (MyListView) findViewById(R.id.want_list);
        want_list_lines = findViewById(R.id.want_list_lines);
        user_linean1 = (LinearLayout) findViewById(R.id.user_linean1);
        user_layout = (LinearLayout) findViewById(R.id.user_layout);
        rl7 = (ImageView) findViewById(R.id.rl7);
        phone_tel = (TextView) findViewById(R.id.phone_tel);
//        call_tel = (LinearLayout) findViewById(R.id.call_tel);
//        sms = (LinearLayout) findViewById(R.id.sms);
        update_lieanr = (LinearLayout) findViewById(R.id.update_lieanr);
        wt_linear = (LinearLayout) findViewById(R.id.wt_linear);
        more_btn_include = (ImageView) findViewById(R.id.more_btn);
        user_name = (TextView) findViewById(R.id.user_name);
        fromlist = (RelativeLayout) findViewById(R.id.fromlist);
        sure_pay = (RelativeLayout) findViewById(R.id.sure_pay);
        bt_over = (RelativeLayout) findViewById(R.id.bt_over);
        customer_seekbar = (SeekBar) findViewById(R.id.customer_seekbar);
        customer_seekbar.setEnabled(false);
        genjin_list = (MyListView) findViewById(R.id.genjin_list);
        genjin_layout = (LinearLayout) findViewById(R.id.genjin_layout);
        rl8 = (ImageView) findViewById(R.id.rl8);
        integrity_view = (TextView) findViewById(R.id.integrity_view);
        user_star = (TextView) findViewById(R.id.user_star);
        user_sex = (TextView) findViewById(R.id.user_sex);
        user_number = (TextView) findViewById(R.id.user_number);
        customerStatus_view = (TextView) findViewById(R.id.customerStatus_view);
        customerOrigin_view = (TextView) findViewById(R.id.customerOrigin_view);
        count1 = (TextView) findViewById(R.id.count1);
        count2 = (TextView) findViewById(R.id.count2);
        count3 = (TextView) findViewById(R.id.count3);
//        rqCourtyardArea_view = (TextView) findViewById(R.id.rqCourtyardArea_view);
//        unit_area = (TextView) findViewById(R.id.unit_area);
//        remark_view = (TextView) findViewById(R.id.remark_view);
        ftContactContent = (TextView) findViewById(R.id.ftContactContent_view);
//        peDocumentNumber = (TextView) findViewById(R.id.peDocumentNumber_vew);
//        peAge = (TextView) findViewById(R.id.peAge_view);
//        peTelephone_view = (TextView) findViewById(R.id.peTelephone_view);
//        peMobile = (TextView) findViewById(R.id.peMobile_view);
//        peWechat_view = (TextView) findViewById(R.id.peWechat_view);
//        peEmail = (TextView) findViewById(R.id.peEmail_view);
//        pePostcode = (TextView) findViewById(R.id.pePostcode_view);
//        peContactAddress = (TextView) findViewById(R.id.peContactAddress_view);
        pePlot_view = (TextView) findViewById(R.id.pePlot_view);
        peDetailedAddress = (TextView) findViewById(R.id.peDetailedAddress_view);
        peWorkaroundAddress_view = (TextView) findViewById(R.id.peWorkaroundAddress_view);
//        reLocalPurchase = (TextView) findViewById(R.id.reLocalPurchase_view);
//        reCurrentHoldings = (TextView) findViewById(R.id.reCurrentHoldings_view);
//        reResidentialMortgage = (TextView) findViewById(R.id.reResidentialMortgage_view);
        play_video = (RelativeLayout) findViewById(R.id.play_video);
        close_btn = (ImageView) findViewById(R.id.close_btn);
        tson_textcontent = (TextView) findViewById(R.id.tson_textcontent);
        image_icon = (ImageView) findViewById(R.id.image_icon);
        type_lk = (LinearLayout) findViewById(R.id.type_lk);
        CallPhone_1 = (LinearLayout) findViewById(R.id.CallPhone_1);
        duotao_image = (ImageView) findViewById(R.id.duotao_image);
        get_type_persong = (TextView) findViewById(R.id.get_type_persong);
        is_selecet_all = (LinearLayout) findViewById(R.id.is_selecet_all);
        recommendedCategory_view = (TextView) findViewById(R.id.recommendedCategory_view);
        recommendedName_view = (TextView) findViewById(R.id.recommendedName_view);
        recommendedMobile_view = (TextView) findViewById(R.id.recommendedMobile_view);
        recommendedUnit_view = (TextView) findViewById(R.id.recommendedUnit_view);
        intentionPropertyType = (TextView) findViewById(R.id.intentionPropertyType);
        // dailyInformation = (TextView) findViewById(R.id.dailyInformation);
//        buyParking = (TextView) findViewById(R.id.buyParking);
        createUserName = (TextView) findViewById(R.id.createUserName);
        attributionName = (TextView) findViewById(R.id.attributionName);
        more_linearlayout = (LinearLayout) findViewById(R.id.more_linearlayout);
        more_title = (TextView) findViewById(R.id.more_title);
        more_icon = (ImageView) findViewById(R.id.more_icon);
//        SupportingLife_list = (MyListView) findViewById(R.id.SupportingLife_list);
//        LifeService_list = (MyListView) findViewById(R.id.LifeService_list);
//        DailyInformationLearningApproach_list = (MyListView) findViewById(R.id.DailyInformationLearningApproach_list);
//        HobbyList_list = (MyListView) findViewById(R.id.HobbyList_list);
//        ATypeOfActivityThatIsWillingToParticipate_list = (MyListView) findViewById(R.id.ATypeOfActivityThatIsWillingToParticipate_list);
        lvInvestigation = (LinearLayout) findViewById(R.id.lv_investigation);
        ivInvestigation = (ImageView) findViewById(R.id.iv_investigation);
        lvInvestigationRoot = (LinearLayout) findViewById(R.id.lv_investigation_root);
        ltvInvestigation = (MyListView) findViewById(R.id.ltv_investigation);
        lvFlag = (LinearLayout) findViewById(R.id.lv_flag);
        lvMoreCustomerFlag = (LinearLayout) findViewById(R.id.lv_more_customer_flag);
        ivFlag = (ImageView) findViewById(R.id.iv_flag);
        ltvMoreCustomer = (MyListView) findViewById(R.id.ltv_more_customer);
        investigationAdapter = new InvestigationAdapter(new ArrayList<queryProjectQuestionnaireList.appProjectQuestionnaireList>());
        ltvInvestigation.setAdapter(investigationAdapter);
        investigationAdapter.setItemClick(new InvestigationAdapter.itemClick() {
            @Override
            public void item(queryProjectQuestionnaireList.appProjectQuestionnaireList itemBean) {
                //跳转webView界面
                Intent intent = new Intent();
                EmmApplication.updateUrl("questionnaire");
                Map<String, String> map = new HashMap<>();
                map.put("version", EmmApplication.getPackageManager(5));
                map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
                map.put("userId", EmmApplication.getUserId());
                map.put("projectId", EmmApplication.getProjectID());
                map.put("questionnaireId", itemBean.getQuestionnaireId());
                map.put("terminalCode", EmmApplication.getPackageManager(2));
                map.put("customerId", customerId);
                Map<String, Object> paramsMap = new HashMap<>();
                paramsMap.put("params", map);
                JSONObject json = new JSONObject(paramsMap);
                String jsonstr = json.toString();
                String url = EmmApplication.urlStr + "?body=" + jsonstr + "";
                intent.putExtra("url", url);
                intent.putExtra("title", "问卷调查");
                intent.setClass(CustomerDetailActivity.this, InvestigationWebView.class);
                startActivity(intent);
            }
        });
        tagListAdapter = new TagListAdapter(new ArrayList<GetTagListBean.TagList>());
        ltvMoreCustomer.setAdapter(tagListAdapter);
        tagListAdapter.setItemClick(new TagListAdapter.itemClick() {
            @Override
            public void item(GetTagListBean.TagList itemBean, int position) {
                String title = itemBean.getTagName();
                Intent intent = new Intent();
                EmmApplication.updateUrl("toCusTagList");
                Map<String, String> map = new HashMap<>();
                map.put("version", EmmApplication.getPackageManager(5));
                map.put("token", EmmApplication.getToken());
                map.put("userId", EmmApplication.getUserId());
                map.put("typeId", itemBean.getTagId());
                map.put("projectId", EmmApplication.getProjectID());
                map.put("customerId", customerId);
                Map<String, Object> paramsMap = new HashMap<>();
                paramsMap.put("params", map);
                JSONObject json = new JSONObject(paramsMap);
                String jsonStr = json.toString();
                String url = EmmApplication.urlStr + "?body=" + jsonStr + "";
                intent.putExtra("url", url);
                intent.putExtra("title", title);
                intent.setClass(CustomerDetailActivity.this, InvestigationWebView.class);
                startActivity(intent);
            }
        });
        queryProjectQuestionnaireList();
        getTagList();
    }

    /**
     * <p>
     * <b>Title：</b> 初始化监听事件以及判断界面展示
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午2:00:00
     */
    private void initBtn() {

        // 判断各模块展开状况
        IsOpenOrClose(cosut_all, IsOpen, rl1);
        IsOpenORcloseMore(IsOpenmore);
        IsOpenOrClose(first_layout, FirtOpen, rl2);
        IsOpenOrClose(user_personal_layout, UserPersonalOpen, rl3);
//        IsOpenOrClose(hometype_layout, HomeType, rl4);
//        IsOpenOrClose(homehouse_layout, HomehouseOpen, rl5);
//        IsOpenOrClose(timephoneopen_layout, TimePhoneOpen, rl6);
        IsOpenOrClose(user_layout, IsUserl, rl7);
        IsOpenOrClose(genjin_layout, IsGenjin, rl8);
        IsOpenOrClose(lvInvestigationRoot, isInvestigation, ivInvestigation);
        IsOpenOrClose(lvFlag, flagCustomer, ivFlag);
        lvInvestigation.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoOpenOrClose();
            }
        });
        // 打电话
        CallPhone_1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (phone_tel.getText().toString() == null || "".equals(phone_tel.getText().toString())
                        || TextUtils.isEmpty(phone_tel.getText().toString())) {
                    return;
                }
                EmmApplication.callPhone(phone_tel.getText().toString(), customerId);
            }
        });

        // 跟进布局
        genjin_layout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoGenjin(IsGenjin);
            }
        });

        // 需求信息
        open_or_close.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoOpenOrClose(IsOpen);
            }
        });

        // 更多
        more_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoOpenORcloseMore(IsOpenmore);
            }
        });

        // 首次接触信息
        firstopen_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoFirtOpenOrClose(FirtOpen);
            }
        });

        // 客户个人信息
        user_personal.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DouserOpenOrClose(UserPersonalOpen);
            }
        });

        //客户标签
        lvFlag.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoOpenOrCloseFlag();
            }
        });

        // 家庭情况
//        hometype_btn.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DoHomeTypeOpenOrClose(HomeType);
//            }
//        });
//
//        // 家庭住宅情况
//        homehouse_btn.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DoHomeHouseTypeOpenOrClose(HomehouseOpen);
//            }
//        });
//
//        // 联系信息
//        timephoneopen_btn.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DoTimePhoneOpenOrClose(TimePhoneOpen);
//            }
//        });

        // 客户信息
        user_linean1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DouserlddetailOpenOrClose(IsUserl);
            }
        });

        // 返回按钮
        back_btn.setVisibility(View.VISIBLE);
        back_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        // 打电话
//        call_tel.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                EmmApplication.callPhone(phone_tel.getText().toString().trim(), customerId);
//            }
//        });
//
//        // 发短信
//        sms.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                List<String> l = new ArrayList<String>();
//                l.add(phone_tel.getText().toString().trim());
//                EmmApplication.sendMMS(l);
//            }
//        });

        // 编辑
        update_lieanr.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                getInitData();
                SetList(2, SupportingLife_set);
                SetList(1, LifeService_set);
                SetList(5, DailyInformationLearningApproach_set);
                SetList(4, HobbyList_set);
                SetList(3, ATypeOfActivityThatIsWillingToParticipate_set);
                EmmApplication.details = details;
                Intent intent = new Intent(CustomerDetailActivity.this, NewCustomerActivity.class);
                intent.putExtra("type_new", 99);
                intent.putExtra("customerId", customerId);
                startActivity(intent);
            }
        });

        // 写跟进
        wt_linear.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CustomerDetailActivity.this, FollowUpActivity.class);
                intent.putExtra("customerId", customerId);
                intent.putExtra("SEX", EmmApplication.isNull(details.getCustomerSex()) ? details.getCustomerSex() : "");
                intent.putExtra("NUMBER", EmmApplication.isNull(details.getIntentionLevel()) ? details.getIntentionLevel()
                        : "");
                intent.putExtra("CUSTOMERSTATUS",
                        EmmApplication.isNull(details.getCustomerStatus()) ? details.getCustomerStatus() : "");
                intent.putExtra("CUSTOMERORIGIN",
                        EmmApplication.isNull(details.getCustomerOrigin()) ? details.getCustomerOrigin() : "");
                intent.putExtra("STAR", EmmApplication.isNull(details.getCustomerStar()) ? details.getCustomerStar() : "");
                intent.putExtra("NAME", EmmApplication.isNull(details.getCustomerName()) ? details.getCustomerName() : "");
                intent.putExtra("TEL", EmmApplication.isNull(details.getCustomerPhone()) ? details.getCustomerPhone() : "");
                startActivity(intent);
            }
        });

        // 菜单按钮
        more_btn_include.setVisibility(View.VISIBLE);
        InitPopuWindow();
        more_btn_include.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (morePopu.isShowing())
                    morePopu.dismiss();
                else
                    morePopu.showAsDropDown(more_btn_include, 0, 0);
            }
        });

        // 拥有认筹权限
        if ("1".equals(EmmApplication.getData(EmmApplication.FROMDETAILSTYPE))) {
            fromlist.setVisibility(View.VISIBLE);
        } else {
            fromlist.setVisibility(View.GONE);
        }

        // 认筹
        fromlist.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CustomerDetailActivity.this, FromListActivity.class);
                intent.putExtra("Dotype", 1);
                intent.putExtra("USERDATA", EmmApplication.isNull(user_name.getText().toString().trim()) ? user_name
                        .getText().toString().trim() : "");
                intent.putExtra("USERTEL", phone_tel.getText().toString().trim());
                intent.putExtra("customerId", customerId);
                startActivity(intent);
            }
        });

        // 认购
        sure_pay.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                EmmApplication.details = details;
                Intent intent = new Intent(CustomerDetailActivity.this, FromListActivity.class);
                intent.putExtra("Dotype", 2);
                intent.putExtra("USERDATA", EmmApplication.isNull(user_name.getText().toString().trim()) ? user_name
                        .getText().toString().trim() : "");
                intent.putExtra("lv", user_number.getText().toString());
                intent.putExtra("USERTEL", phone_tel.getText().toString().trim());
                intent.putExtra("customerId", customerId);
                startActivity(intent);
            }
        });

        // 签约
        bt_over.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                EmmApplication.details = details;
                Intent intent = new Intent(CustomerDetailActivity.this, FromListActivity.class);
                intent.putExtra("Dotype", 3);
                intent.putExtra("USERDATA", EmmApplication.isNull(user_name.getText().toString().trim()) ? user_name
                        .getText().toString().trim() : "");
                intent.putExtra("lv", user_number.getText().toString());
                intent.putExtra("USERTEL", phone_tel.getText().toString().trim());
                intent.putExtra("customerId", customerId);
                startActivity(intent);
            }
        });

        // 播放录音时的关闭按钮
        close_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (openaac == 0) {
                    if (mp != null) {
                        mp.pause();
                    }
                } else {
                    isPlaying = false;
                }
                EmmApplication.setVideo(EmmApplication.current);
                play_video.setVisibility(View.GONE);
                handler.removeMessages(99);
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });

        // 播放录音布局
        play_video.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 不做处理,消耗点击事件
                Log.v(TAG, "play_video-->");
            }
        });

        // 意向房源更多
        more_linearlayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (1 == hgadapter.GetExhibitiontype()) {
                    hgadapter.SetExhibitiontype(0);
                    more_title.setText("收起");
                    more_icon.setImageResource(R.drawable.icon_10);
                } else {
                    hgadapter.SetExhibitiontype(1);
                    more_title.setText("更多");
                    more_icon.setImageResource(R.drawable.icon_08);
                }
            }
        });

    }

    /**
     * <p>
     * <b>Title：</b> 判断各模块展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param view
     * @param bl
     * @param view2
     * @author tangxin
     * @date 2016年12月7日 下午2:02:32
     */
    private void IsOpenOrClose(View view, boolean bl, ImageView view2) {
        if (bl) {
            view.setVisibility(View.VISIBLE);
            view2.setImageResource(R.drawable.j_bottom);
        } else {
            view.setVisibility(View.GONE);
            view2.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的需求模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:02:40
     */
    private void DoOpenOrClose(boolean bl) {
        if (!bl) {
            IsOpen = true;
            cosut_all.setVisibility(View.VISIBLE);
            rl1.setImageResource(R.drawable.j_bottom);
        } else {
            IsOpen = false;
            cosut_all.setVisibility(View.GONE);
            rl1.setImageResource(R.drawable.j_top);
        }
    }

    private void DoOpenOrClose() {
        if (isInvestigation) {
            isInvestigation = false;
            ivInvestigation.setImageResource(R.drawable.j_top);
            lvInvestigationRoot.setVisibility(View.GONE);
        } else {
            isInvestigation = true;
            lvInvestigationRoot.setVisibility(View.VISIBLE);
            ivInvestigation.setImageResource(R.drawable.j_bottom);
        }
    }

    private void DoOpenOrCloseFlag() {
        if (flagCustomer) {
            flagCustomer = false;
            ivFlag.setImageResource(R.drawable.j_top);
            lvMoreCustomerFlag.setVisibility(View.GONE);
        } else {
            flagCustomer = true;
            lvMoreCustomerFlag.setVisibility(View.VISIBLE);
            ivFlag.setImageResource(R.drawable.j_bottom);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 初始化字典多选项适配器
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param adapter
     * @param type
     * @return
     * @author tangxin
     * @date 2017年2月20日 上午10:23:42
     */
    private void InitAdapter(MultiInterfaceAdapter adapter, int type, ListView listview, ArrayList<RqBusNumList> list) {
        SetList(type, list);
        if (null == adapter) {
            adapter = new MultiInterfaceAdapter(CustomerDetailActivity.this, list, type);
            listview.setAdapter(adapter);
        } else {
            adapter.NotifyData(list);
        }

        adapter.SetIsVisible(3);
    }

    private void SetList(int type, ArrayList<RqBusNumList> list) {
        switch (type) {
            case 1:
                EmmApplication.LifeService = list;
                break;
            case 2:
                EmmApplication.SupportingLife = list;
                break;
            case 3:
                EmmApplication.ATypeOfActivityThatIsWillingToParticipate = list;
                break;
            case 4:
                EmmApplication.HobbyList = list;
                break;
            case 5:
                EmmApplication.DailyInformationLearningApproach = list;
                break;
            default:
                break;
        }
    }

    /**
     * <p>
     * <b>Title：</b> 获取初始加载数据
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2017年2月27日 上午10:15:02
     */
    private void getInitData() {

        // 生活配套
        SupportingLife_set = new ArrayList<RqBusNumList>();
        if (null != details.getCustomerLifeSupportList() && details.getCustomerLifeSupportList().size() > 0) {
            for (int i2 = 0; i2 < details.getCustomerLifeSupportList().size(); i2++) {
                RqBusNumList rqbean = new RqBusNumList();
                rqbean.setDictionaryId(details.getCustomerLifeSupportList().get(i2).getLifeSupportId());
                rqbean.setDictionaryName(details.getCustomerLifeSupportList().get(i2).getLifeSupportName());
                rqbean.setSelect(true);
                SupportingLife_set.add(rqbean);
            }
        }

        // 生活服务
        LifeService_set = new ArrayList<RqBusNumList>();
        if (null != details.getCustomeServicesList() && details.getCustomeServicesList().size() > 0) {
            for (int i2 = 0; i2 < details.getCustomeServicesList().size(); i2++) {
                RqBusNumList rqbean = new RqBusNumList();
                rqbean.setDictionaryId(details.getCustomeServicesList().get(i2).getServicesId());
                rqbean.setDictionaryName(details.getCustomeServicesList().get(i2).getServicesName());
                rqbean.setSelect(true);
                LifeService_set.add(rqbean);
            }
        }

        // 日常信息获知途径
        DailyInformationLearningApproach_set = new ArrayList<RqBusNumList>();
        if (null != details.getCustomerDailyInformationList() && details.getCustomerDailyInformationList().size() > 0) {
            for (int i2 = 0; i2 < details.getCustomerDailyInformationList().size(); i2++) {
                RqBusNumList rqbean = new RqBusNumList();
                rqbean.setDictionaryId(details.getCustomerDailyInformationList().get(i2).getDailyInformationId());
                rqbean.setDictionaryName(details.getCustomerDailyInformationList().get(i2).getDailyInformationName());
                rqbean.setSelect(true);
                DailyInformationLearningApproach_set.add(rqbean);
            }
        }

        // 兴趣爱好
        HobbyList_set = new ArrayList<RqBusNumList>();
        if (null != details.getCustomerHobbyList() && details.getCustomerHobbyList().size() > 0) {
            for (int i2 = 0; i2 < details.getCustomerHobbyList().size(); i2++) {
                RqBusNumList rqbean = new RqBusNumList();
                rqbean.setDictionaryId(details.getCustomerHobbyList().get(i2).getHobbyId());
                rqbean.setDictionaryName(details.getCustomerHobbyList().get(i2).getHobbyName());
                rqbean.setSelect(true);
                HobbyList_set.add(rqbean);
            }
        }

        // 乐于参加的活动类型
        ATypeOfActivityThatIsWillingToParticipate_set = new ArrayList<RqBusNumList>();
        if (null != details.getCustomerActivityTypeList() && details.getCustomerActivityTypeList().size() > 0) {
            for (int i2 = 0; i2 < details.getCustomerActivityTypeList().size(); i2++) {
                RqBusNumList rqbean = new RqBusNumList();
                rqbean.setDictionaryId(details.getCustomerActivityTypeList().get(i2).getActivityTypeId());
                rqbean.setDictionaryName(details.getCustomerActivityTypeList().get(i2).getActivityTypeName());
                rqbean.setSelect(true);
                ATypeOfActivityThatIsWillingToParticipate_set.add(rqbean);
            }
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断跟进模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:02:51
     */
    private void DoGenjin(boolean bl) {
        if (!bl) {
            IsGenjin = true;
            genjin_list.setVisibility(View.VISIBLE);
            rl8.setImageResource(R.drawable.j_bottom);
        } else {
            IsGenjin = false;
            genjin_list.setVisibility(View.GONE);
            rl8.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 是否展开更多模块
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:02:59
     */
    private void IsOpenORcloseMore(boolean bl) {
        if (bl) {
            more_btn.setText("收起");
            more_layout.setVisibility(View.VISIBLE);
        } else {
            more_btn.setText("更多");
            more_layout.setVisibility(View.GONE);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的更多模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:03:08
     */
    private void DoOpenORcloseMore(boolean bl) {
        if (!bl) {
            more_btn.setText("收起");
            IsOpenmore = true;
            more_layout.setVisibility(View.VISIBLE);
        } else {
            more_btn.setText("更多");
            IsOpenmore = false;
            more_layout.setVisibility(View.GONE);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的首次接触的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:03:18
     */
    private void DoFirtOpenOrClose(boolean bl) {
        if (!bl) {
            FirtOpen = true;
            first_layout.setVisibility(View.VISIBLE);
            rl2.setImageResource(R.drawable.j_bottom);
        } else {
            FirtOpen = false;
            first_layout.setVisibility(View.GONE);
            rl2.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的首次接触的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:03:26
     */
    private void DouserOpenOrClose(boolean bl) {
        if (!bl) {
            UserPersonalOpen = true;
            user_personal_layout.setVisibility(View.VISIBLE);
            rl3.setImageResource(R.drawable.j_bottom);
        } else {
            UserPersonalOpen = false;
            user_personal_layout.setVisibility(View.GONE);
            rl3.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的家庭情况的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:04:53
     */
//    private void DoHomeTypeOpenOrClose(boolean bl) {
//        if (!bl) {
//            HomeType = true;
//            hometype_layout.setVisibility(View.VISIBLE);
//            rl4.setImageResource(R.drawable.j_bottom);
//        } else {
//            HomeType = false;
//            hometype_layout.setVisibility(View.GONE);
//            rl4.setImageResource(R.drawable.j_top);
//        }
//    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的家庭住宅情况的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:05:02
     */
//    private void DoHomeHouseTypeOpenOrClose(boolean bl) {
//        if (!bl) {
//            HomehouseOpen = true;
//            homehouse_layout.setVisibility(View.VISIBLE);
//            rl5.setImageResource(R.drawable.j_bottom);
//        } else {
//            HomehouseOpen = false;
//            homehouse_layout.setVisibility(View.GONE);
//            rl5.setImageResource(R.drawable.j_top);
//        }
//    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的联系情况的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:05:14
     */
//    private void DoTimePhoneOpenOrClose(boolean bl) {
//        if (!bl) {
//            TimePhoneOpen = true;
//            timephoneopen_layout.setVisibility(View.VISIBLE);
//            rl6.setImageResource(R.drawable.j_bottom);
//        } else {
//            TimePhoneOpen = false;
//            timephoneopen_layout.setVisibility(View.GONE);
//            rl6.setImageResource(R.drawable.j_top);
//        }
//    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的联系情况的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午2:05:23
     */
    private void DouserlddetailOpenOrClose(boolean bl) {
        if (!bl) {
            IsUserl = true;
            user_layout.setVisibility(View.VISIBLE);
            rl7.setImageResource(R.drawable.j_bottom);
        } else {
            IsUserl = false;
            user_layout.setVisibility(View.GONE);
            rl7.setImageResource(R.drawable.j_top);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        BaseActivity.activity = this;

        // 客户是否刷新
        if (EmmApplication.IS_RELOAD_DETAILS) {
            EmmApplication.IS_RELOAD_DETAILS = false;
            EmmApplication.IS_RELOAD = true;
            getFollowList(customerId);
        }

        // 注册广播接收
        IntentFilter filter = new IntentFilter(EmmApplication.NEW_CUSTOMER_DETAILS);
        registerReceiver(mBroadcastReceiver, filter);
        IntentFilter filter2 = new IntentFilter(EmmApplication.SendOpenVideo2);
        registerReceiver(mBroadcastReceiver, filter2);

    }

    /**
     * 播放器
     */
    MediaPlayer mp;
    int openaac = 0;

    /**
     * 广播，主要做刷新以及播放录音
     */
    private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(EmmApplication.NEW_CUSTOMER_DETAILS_LIST)) {
                // 刷新动作
                Log.v(TAG, "---------刷新动作----------");
                EmmApplication.IS_RELOAD = true;
                getFollowList(customerId);
            }
            if (action.equals(EmmApplication.NEW_CUSTOMER_DETAILS)) {
                // 刷新动作
                Log.v(TAG, "---------刷新动作----------");
                EmmApplication.IS_RELOAD = true;
                getFollowList(customerId);
            }
            if (action.equals(EmmApplication.SendOpenVideo2)) {
                // 播录音
                audioFile = EmmApplication.OpenPath;// 得到路径，重置值给播放提供条件
                Log.v(TAG, "audioFile.toString()" + audioFile.toString());

                // 判断录音类型(条件中为开发历史中使用过的类型，需要特例出来兼容)
                if ("aac".equals(audioFile.toString().substring(audioFile.toString().length() - 3,
                        audioFile.toString().length()))
                        || "mp3".equals(audioFile.toString().substring(audioFile.toString().length() - 3,
                        audioFile.toString().length()))
                        || "wav".equals(audioFile.toString().substring(audioFile.toString().length() - 3,
                        audioFile.toString().length()))
                        || "WAV".equals(audioFile.toString().substring(audioFile.toString().length() - 3,
                        audioFile.toString().length()))) {
                    openaac = 0;
                    EmmApplication.getVideo();// 得到当前媒体音量
                    EmmApplication.setVideo(EmmApplication.max);// 设置为最大音量
                    count = 1;
                    // UI更新(动画效果)
                    handler.sendEmptyMessage(99);
                    play_video.setVisibility(View.VISIBLE);
                    mp = new MediaPlayer();

                    try {
                        mp.setDataSource(audioFile.toString());
                        mp.prepare();
                        mp.start();
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (IllegalStateException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    // 播放状态监听
                    mp.setOnCompletionListener(new OnCompletionListener() {
                        @Override
                        public void onCompletion(MediaPlayer mp) {
                            Log.v(TAG, "播放完成:->");
                            mp.release();
                            EmmApplication.setVideo(EmmApplication.current);// 将最大音量恢复回之前音量
                            EmmApplication.setLog(CustomerDetailActivity.this);
                            play_video.setVisibility(View.GONE);
                            handler.removeMessages(99);// 销毁更新UI的handler
                        }
                    });
                } else {// 解析成流播放
                    openaac = 1;
                    if (isPlaying) {
                        EmmApplication.showTips("正在播放");
                    } else {
                        EmmApplication.getVideo();// 得到当前媒体音量
                        EmmApplication.setVideo(EmmApplication.max);// 设置为最大音量
                        count = 1;
                        handler.sendEmptyMessage(99);
                        play_video.setVisibility(View.VISIBLE);
                        player = new PlayTask();// 开始播放
                        player.execute();
                    }
                }
            }
        }
    };

    protected void onDestroy() {
        super.onDestroy();

        // 注销广播
        unregisterReceiver(mBroadcastReceiver);

        // 对MediaPlayer做release操作
        if (null != mp) {
            mp.release();
            EmmApplication.setVideo(EmmApplication.current);
        }

        // 清空关注重点缓存
        if (EmmApplication.RqFocus != null) {
            EmmApplication.RqFocus.clear();
        }

        EmmApplication.IsLoadingCustomer = false;// 解除跳转限制
        EmmApplication.IsLoadingFromList = false;// 解除限制
        EmmApplication.housinglist.clear();
        EmmApplication.attentionlist.clear();
        EmmApplication.grouplist.clear();
        EmmApplication.RqFocus.clear();
        EmmApplication.LifeService.clear();
        EmmApplication.SupportingLife.clear();
        EmmApplication.ATypeOfActivityThatIsWillingToParticipate.clear();
        EmmApplication.HobbyList.clear();
        EmmApplication.DailyInformationLearningApproach.clear();
    }


    /**
     * 伪异步处理界面展示，防止阻塞UI线程
     */
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) { // handle message
            switch (msg.what) {
                case 99:
                    if (count == 0) {
                        handler.removeMessages(99);
                    } else {// 播放录音的动画
                        if (count % 4 == 0) {
                            image_icon.setImageResource(R.drawable.a01v);
                        } else if (count % 4 == 1) {
                            image_icon.setImageResource(R.drawable.a02v);
                        } else if (count % 4 == 2) {
                            image_icon.setImageResource(R.drawable.a03v);
                        } else if (count % 4 == 3) {
                            image_icon.setImageResource(R.drawable.a04v);
                        }
                        count++;
                        Message message = handler.obtainMessage(99);
                        handler.sendMessageDelayed(message, 500);
                    }
                    break;
                case 88:
                    EmmApplication.setVideo(EmmApplication.current);
                    play_video.setVisibility(View.GONE);
                    handler.removeMessages(99);
                    EmmApplication.setLog(CustomerDetailActivity.this);
                    break;
            }
            super.handleMessage(msg);
        }
    };

    /**
     * 播放标识 0为未播放
     */
    int count;
    private int frequence = 16000;// 8000;

    private int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;

    private int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;

    /**
     * 标记
     */
    private boolean isPlaying = false;

    /**
     * 通过流的播放器
     */
    private PlayTask player;

    /**
     * 最近对应名
     */
    private File audioFile;

    /**
     * <p>
     * <b>Title：</b> 播放时，需要传入路径
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午2:06:40
     */
    class PlayTask extends AsyncTask<Void, Integer, Void> {

        @Override
        protected Void doInBackground(Void... arg0) {
            isPlaying = true;
            int bufferSize = AudioTrack.getMinBufferSize(frequence, channelConfig, audioEncoding);
            short[] buffer = new short[bufferSize / 4];
            try {
                Log.w("路径:", "" + audioFile);
                // 定义输入流，将音频写入到AudioTrack类中，实现播放
                DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(audioFile)));
                // 实例AudioTrack
                AudioTrack track = new AudioTrack(AudioManager.STREAM_MUSIC, frequence, channelConfig, audioEncoding,
                        bufferSize, AudioTrack.MODE_STREAM);
                // 开始播放
                track.play();
                // 由于AudioTrack播放的是流，所以，我们需要一边播放一边读取
                while (isPlaying && dis.available() > 0) {
                    int i = 0;
                    while (dis.available() > 0 && i < buffer.length) {
                        buffer[i] = dis.readShort();
                        i++;
                    }
                    // 然后将数据写入到AudioTrack中
                    track.write(buffer, 0, buffer.length);
                }
                // 播放结束
                track.stop();
                dis.close();
                isPlaying = false;// 重置标识
                handler.sendEmptyMessage(88);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        protected void onPostExecute(Void result) {
        }

        protected void onPreExecute() {
        }
    }

    /**
     * 菜单
     */
    PopupWindow morePopu;

    /**
     * 菜单
     */
    View viewpopu;

    /**
     * <p>
     * <b>Title：</b> 初始化菜单PopupWindow
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午2:06:57
     */
    @SuppressWarnings("deprecation")
    public void InitPopuWindow() {
        viewpopu = LayoutInflater.from(CustomerDetailActivity.this).inflate(R.layout.morep, null);
        morePopu = new PopupWindow(viewpopu, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        // 设置焦点
        morePopu.setFocusable(true);
        morePopu.setOutsideTouchable(true);
        // view的焦点
        viewpopu.setFocusable(true);
        viewpopu.setFocusableInTouchMode(true);
        // 监听back按钮
        viewpopu.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    morePopu.dismiss();
                }
                return false;
            }
        });
        viewpopu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                morePopu.dismiss();
            }
        });
        LinearLayout search = (LinearLayout) viewpopu.findViewById(R.id.search);
        LinearLayout sms = (LinearLayout) viewpopu.findViewById(R.id.sms);
        LinearLayout add_coustomer = (LinearLayout) viewpopu.findViewById(R.id.add_coustomer);
        LinearLayout allot = (LinearLayout) viewpopu.findViewById(R.id.allot);
        LinearLayout add_form = (LinearLayout) viewpopu.findViewById(R.id.add_form);
        LinearLayout add_phone = (LinearLayout) viewpopu.findViewById(R.id.add_phone);
        View lines_1 = viewpopu.findViewById(R.id.lines_1);
        View lines_2 = viewpopu.findViewById(R.id.lines_2);
        View lines_3 = viewpopu.findViewById(R.id.lines_3);
        View lines_3s = viewpopu.findViewById(R.id.lines_3s);
        View lines_4 = viewpopu.findViewById(R.id.lines_4);
        TextView pad = (TextView) viewpopu.findViewById(R.id.pad);
        pad.setText("分配");

        // 拥有认筹权限
        if ("1".equals(EmmApplication.getData(EmmApplication.FROMDETAILSTYPE))) {
            lines_4.setVisibility(View.VISIBLE);
            add_form.setVisibility(View.VISIBLE);
        } else {
            lines_4.setVisibility(View.GONE);
            add_form.setVisibility(View.GONE);
        }

        // 分配权限
        if ("1".equals(EmmApplication.getData(EmmApplication.isDistributionCustomer))) {
            lines_3s.setVisibility(View.VISIBLE);
            allot.setVisibility(View.VISIBLE);
        } else {
            lines_3s.setVisibility(View.GONE);
            allot.setVisibility(View.GONE);
        }

        search.setVisibility(View.GONE);
        sms.setVisibility(View.GONE);
        add_coustomer.setVisibility(View.GONE);
        lines_1.setVisibility(View.GONE);
        lines_2.setVisibility(View.GONE);
        lines_3.setVisibility(View.GONE);

        // 添加到通讯录
        add_phone.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                morePopu.dismiss();
                RxPermissions rxPermission = new RxPermissions(CustomerDetailActivity.this);
                rxPermission.requestEach(WRITE_CONTACTS, READ_CONTACTS, GET_ACCOUNTS)
                        .subscribe(new Consumer<Permission>() {
                            @Override
                            public void accept(Permission permission) throws Exception {
                                if (permission.granted) {
                                    insert(EmmApplication.isNull(user_name.getText().toString().trim()) ? user_name.getText().toString()
                                            .trim() : "", phone_tel.getText().toString().trim(), null, null);
                                } else if (permission.shouldShowRequestPermissionRationale) {
                                } else {
                                }
                            }
                        });
            }
        });

        // 分配
        allot.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                morePopu.dismiss();
                getConsultantList();
            }
        });

        // 新增认筹
        add_form.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                morePopu.dismiss();
                Intent intent = new Intent(CustomerDetailActivity.this, NewFromActivity.class);
                intent.putExtra("customerId", customerId);
                startActivity(intent);
            }
        });
    }

    /**
     * 查询置业顾问列表数据源
     */
    GetConsultantList getconsultan;

    /**
     * <p>
     * <b>Title：</b> 查询置业顾问列表
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午2:07:19
     */
    private void getConsultantList() {
        EmmApplication.updateUrl("getConsultantList");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectId", EmmApplication.getProjectID());
        map.put("projectCode", EmmApplication.getProjectCode());
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v(TAG, "getConsultantList-->post:" + EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.showDialogForLoading(CustomerDetailActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v("置业顾问content", content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                getconsultan = JSONObject.parseObject(resData.toString(), GetConsultantList.class);
                if ("1".equals(getconsultan.getResult())) {
                    Log.v("获取成功", "");
                    if (getconsultan != null && getconsultan.getConsultantList() != null) {
                        if (getconsultan.getConsultantList().size() > 0) {
                            SetzpPopu2(getconsultan.getConsultantList());
                        } else {
                            EmmApplication.T("当前没有置业顾问");
                        }
                    } else {
                        EmmApplication.T("当前没有置业顾问");
                    }
                } else {
                    EmmApplication.T(getconsultan.getErrorMsg().toString());
                    try {
                        Log.v("获取失败", "errorCode:" + getconsultan.getErrorCode().toString() + "errorMsg:"
                                + getconsultan.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("查询置业顾问", "错误信息获取空指针异常");
                    }
                }
            }
        });
    }

    /**
     * 被分配对象
     */
    ArrayList<CustomerListinfo> customerList = new ArrayList<CustomerDetailActivity.CustomerListinfo>();

    /**
     * <p>
     * <b>Title：</b> 菜单项--分配
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param consultantList
     * @author tangxin
     * @date 2016年12月7日 下午2:07:27
     */
    public void SetzpPopu2(final ArrayList<ConsultantList> consultantList) {
        viewzp = LayoutInflater.from(CustomerDetailActivity.this).inflate(R.layout.popu_zp, null);
        popuzp = new PopupWindow(viewzp, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
                android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
        popuzp.setFocusable(true);
        popuzp.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popuzp.showAtLocation(viewzp, Gravity.BOTTOM, 0, 0);
        popuzp.showAsDropDown(viewzp, 0, 0);
        popuzp.setOutsideTouchable(true);
        viewzp.setFocusable(true);
        viewzp.setFocusableInTouchMode(true);
        viewzp.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    popuzp.dismiss();
                    EmmApplication.setLog(CustomerDetailActivity.this);
                }
                return false;
            }
        });
        viewzp.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });

        PickerView select_pick = (PickerView) viewzp.findViewById(R.id.select_pick);

        // 将指派对象的数据加入滑动控件的数据源
        ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i < consultantList.size(); i++) {
            list.add(consultantList.get(i).getConsultantUserName());
        }
        selectName = list.get(0);

        TextView shuerbtn = (TextView) viewzp.findViewById(R.id.shuerbtn);

        ImageView dis_btn = (ImageView) viewzp.findViewById(R.id.dis_btn);

        dis_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });

        RelativeLayout relative_all = (RelativeLayout) viewzp.findViewById(R.id.relative_all);

        // 绑定数据
        select_pick.setData(list);
        select_pick.setOnSelectListener(new onSelectListener() {
            @Override
            public void onSelect(String text, int id) {
                // 获取选中的
                selectName = text;
                SelectID = id;
            }
        });

        // 默认选择第一个
        select_pick.setSelected(0);
        shuerbtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 确定
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
                String consultantUserId = null;
                for (int i = 0; i < consultantList.size(); i++) {
                    if (selectName.equals(consultantList.get(i).getConsultantUserName())) {
                        consultantUserId = consultantList.get(i).getConsultantUserId();
                        break;
                    }
                }

                // 分配置业顾问接口
                distributionConsultant(consultantUserId, customerList);
            }
        });
        relative_all.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 消耗点击事件
            }
        });
    }

    /**
     * 分配置业顾问接口
     */
    DistributionConsultant distribution;

    /**
     * <p>
     * <b>Title：</b> 分配置业顾问接口
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param consultantUserId 置业顾问ID
     * @param customerList
     * @author tangxin
     * @date 2016年12月7日 下午2:07:41
     */
    private void distributionConsultant(String consultantUserId, ArrayList<CustomerListinfo> customerList) {

        CustomerListinfo info = new CustomerListinfo();
        info.customerId = customerId;
        customerList.add(info);

        EmmApplication.updateUrl("distributionConsultant");
        Map<String, Object> map = new HashMap<String, Object>();

        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("consultantUserId", consultantUserId);
        map.put("customerList", customerList);
        map.put("projectId", EmmApplication.getProjectID());

        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v(TAG, "distributionConsultant-->post:" + EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.showDialogForLoading(CustomerDetailActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v("置业顾问content", content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                distribution = JSONObject.parseObject(resData.toString(), DistributionConsultant.class);
                if ("1".equals(distribution.getResult())) {
                    Log.v("获取成功", "");
                    EmmApplication.IS_RELOAD = true;
                    attributionName.setText(selectName);
                    EmmApplication.T("分配成功");
                } else {
                    try {
                        EmmApplication.T(distribution.getErrorMsg().toString());
                        Log.v("获取失败", "errorCode:" + distribution.getErrorCode().toString() + "errorMsg:"
                                + distribution.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("distribution", "错误信息获取空指针异常");
                    }
                }
            }
        });
    }

    public class CustomerListinfo {
        private String customerId;// 被分配客户

        public String getCustomerId() {
            return customerId;
        }

        public void setCustomerId(String customerId) {
            this.customerId = customerId;
        }
    }

    /**
     * <p>
     * <b>Title：插入通讯录 </b>
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param given_name    姓名
     * @param mobile_number 电话
     * @param work_email    邮件
     * @param im_qq         QQ
     * @return
     * @author tangxin
     * @date 2016年12月7日 下午2:08:07
     */
    public boolean insert(String given_name, String mobile_number, String work_email, String im_qq) {
        try {
            ContentValues values = new ContentValues();

            // 下面的操作会根据RawContacts表中已有的rawContactId使用情况自动生成新联系人的rawContactId
            Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
            long rawContactId = ContentUris.parseId(rawContactUri);

            // 向data表插入姓名数据
            if (given_name != "") {
                values.clear();
                values.put(Data.RAW_CONTACT_ID, rawContactId);
                values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
                values.put(StructuredName.GIVEN_NAME, given_name);
                getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
            }

            // 向data表插入电话数据
            if (mobile_number != "") {
                values.clear();
                values.put(Data.RAW_CONTACT_ID, rawContactId);
                values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
                values.put(Phone.NUMBER, mobile_number);
                values.put(Phone.TYPE, Phone.TYPE_MOBILE);
                getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
            }

            // 向data表插入Email数据
            if (work_email != "") {
                values.clear();
                values.put(Data.RAW_CONTACT_ID, rawContactId);
                values.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
                values.put(Email.DATA, work_email);
                values.put(Email.TYPE, Email.TYPE_WORK);
                getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
            }

            // 向data表插入QQ数据
            if (im_qq != "") {
                values.clear();
                values.put(Data.RAW_CONTACT_ID, rawContactId);
                values.put(Data.MIMETYPE, Im.CONTENT_ITEM_TYPE);
                values.put(Im.DATA, im_qq);
                values.put(Im.PROTOCOL, Im.PROTOCOL_QQ);
                getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
            }
            // 向data表插入头像数据
            Bitmap sourceBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.logo180);
            final ByteArrayOutputStream os = new ByteArrayOutputStream();
            // 将Bitmap压缩成PNG编码，质量为100%存储
            sourceBitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
            byte[] avatar = os.toByteArray();
            values.put(Data.RAW_CONTACT_ID, rawContactId);
            values.put(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE);
            values.put(Photo.PHOTO, avatar);
            getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
        } catch (Exception e) {
            EmmApplication.T("添加到通讯录失败！请检查信息和权限是否正确");
            return false;
        }
        EmmApplication.T("已成功添加到通讯录");
        return true;
    }

    /**
     * <p>
     * <b>Title：</b> 分配（暂时未被调用）
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param listname
     * @author tangxin
     * @date 2016年12月7日 下午2:08:41
     */
    private void SetzpPopu(final List<String> listname) {
        viewzp = LayoutInflater.from(CustomerDetailActivity.this).inflate(R.layout.popu_zp, null);
        popuzp = new PopupWindow(viewzp, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
                android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
        popuzp.setFocusable(true);
        popuzp.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popuzp.showAtLocation(viewzp, Gravity.BOTTOM, 0, 0);
        popuzp.showAsDropDown(viewzp, 0, 0);
        popuzp.setFocusable(true);
        popuzp.setOutsideTouchable(true);
        viewzp.setFocusable(true);
        viewzp.setFocusableInTouchMode(true);
        viewzp.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    popuzp.dismiss();
                    EmmApplication.setLog(CustomerDetailActivity.this);
                }
                return false;
            }
        });
        viewzp.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });

        PickerView select_pick = (PickerView) viewzp.findViewById(R.id.select_pick);

        selectName = listname.get(0);

        TextView shuerbtn = (TextView) viewzp.findViewById(R.id.shuerbtn);
        RelativeLayout relative_all = (RelativeLayout) viewzp.findViewById(R.id.relative_all);
        ImageView dis_btn = (ImageView) viewzp.findViewById(R.id.dis_btn);
        dis_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });
        select_pick.setData(listname);
        select_pick.setOnSelectListener(new onSelectListener() {
            @Override
            public void onSelect(String text, int id) {
                selectName = text;
                SelectID = id;
            }
        });
        select_pick.setSelected(0);
        shuerbtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 确定
                popuzp.dismiss();
                EmmApplication.setLog(CustomerDetailActivity.this);
            }
        });
        relative_all.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }

    /**
     * <p>
     * <b>Title：</b> 根据ID绑定view
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月21日 下午5:09:59
     */
    private void initView2() {
//        qqnum = (TextView) findViewById(R.id.qqnum);
//        industry = (TextView) findViewById(R.id.industry);
//        natureCompany = (TextView) findViewById(R.id.natureCompany);
//        annualTurnoverCompany = (TextView) findViewById(R.id.annualTurnoverCompany);
//        familyStructure = (TextView) findViewById(R.id.familyStructure);
//        isEmployees = (TextView) findViewById(R.id.isEmployees);
//        isOwnerCompany = (TextView) findViewById(R.id.isOwnerCompany);
//        isLiveElderly = (TextView) findViewById(R.id.isLiveElderly);
//        isChildren = (TextView) findViewById(R.id.isChildren);
        lvIntentionLevel = (LinearLayout) findViewById(R.id.lv_intention_level);
        tvIntentionLevelRemark = (TextView) findViewById(R.id.tv_IntentionLevelRemark);
        vIntentionLv = findViewById(R.id.v_intention_lv);
    }

    /**
     * <p>
     * <b>Title：</b> 客户详情
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param customerId
     * @author tangxin
     * @date 2016年12月7日 下午2:08:55
     */
    private void getCustomerDetail(String customerId) {
        EmmApplication.updateUrl("getCustomerDetail");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("customerId", customerId);
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v(TAG, "getCustomerDetail-->post:" + EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v(TAG, "content：" + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                details = JSONObject.parseObject(resData.toString(), GetCustomerDetail.class);
                if ("1".equals(details.getResult())) {
                    Log.v("获取成功", "");

                    createUserName.setText(EmmApplication.isNull(details.getCreateUserName()) ? details
                            .getCreateUserName() : "");

                    attributionName.setText(EmmApplication.isNull(details.getAttributionName()) ? details
                            .getAttributionName() : "");

                    intentionPropertyType.setText(EmmApplication.isNull(details.getIntentionPropertyType()) ? details
                            .getIntentionPropertyType() : "");

                    // dailyInformation.setText(EmmApplication.isNull(details.getDailyInformation())
                    // ? details
                    // .getDailyInformation() : "");

//                    buyParking.setText(EmmApplication.isNull(details.getBuyParking()) ? details.getBuyParking() : "");
//
//                    qqnum.setText(details.getQqNum());
//
//                    industry.setText(details.getIndustry());
//
//                    natureCompany.setText(details.getNatureCompany());
//
//                    annualTurnoverCompany.setText(details.getAnnualTurnoverCompany());
//
//                    familyStructure.setText(details.getFamilyStructure());
//
//                    isEmployees.setText(details.getIsEmployees());
//
//                    isOwnerCompany.setText(details.getIsOwnerCompany());
//
//                    isLiveElderly.setText(details.getIsLiveElderly());
//
//                    isChildren.setText(details.getIsChildren());

                    String styy = details.getIsMoreTrade();// 多套标识
                    if ("1".equals(styy)) {
                        duotao_image.setVisibility(View.VISIBLE);
                    } else {
                        duotao_image.setVisibility(View.INVISIBLE);
                    }

                    String informedway = details.getInformedWay();

                    get_type_persong.setText(informedway);

                    if ("全员营销".equals(informedway) || "外部推荐".equals(informedway)) {
                        is_selecet_all.setVisibility(View.VISIBLE);
                        recommendedCategory_view.setText(details.getRecommendedCategory());
                        recommendedName_view.setText(details.getRecommendedName());
                        recommendedMobile_view.setText(details.getRecommendedMobile());
                        recommendedUnit_view.setText(details.getRecommendedUnit());
                    } else {
                        is_selecet_all.setVisibility(View.GONE);
                    }

                    integrity_view.setText("资料完成度 "
                            + (int) Double.valueOf(EmmApplication.removed(details.getIntegrity())).doubleValue() + "%");// 资料完善度显示
                    try {
                        customer_seekbar.setProgress((int) Double.valueOf(EmmApplication.removed(details.getIntegrity()))
                                .doubleValue());// 进度条进度设置
                    } catch (NullPointerException e) {
                        customer_seekbar.setProgress(0);
                    }

                    user_name.setText(details.getCustomerName());
                    if (null != details.getCustomerStar() && !"".equals(details.getCustomerStar())) {
                        user_star.setVisibility("是".equals(details.getCustomerStar()) == true ? View.VISIBLE
                                : View.INVISIBLE);
                    } else {
                        user_star.setVisibility(View.INVISIBLE);
                    }

                    user_sex.setText(details.getCustomerSex());
                    user_number.setText(details.getIntentionLevel());
                    phone_tel.setText(details.getCustomerPhone());

                    customerStatus_view.setText(details.getCustomerStatus());
                    customerOrigin_view.setText(details.getCustomerOrigin());

                    count1.setText(Integer.valueOf(details.getPayDepositNum()).intValue() > 99 ? "99+" : details
                            .getPayDepositNum());
                    count2.setText(Integer.valueOf(details.getSubscribeNum()).intValue() > 99 ? "99+" : details
                            .getSubscribeNum());
                    count3.setText(Integer.valueOf(details.getSignedNum()).intValue() > 99 ? "99+" : details
                            .getSignedNum());
                    set_incentive.setText(details.getRqTheirMotives());
                    // 关注重点
                    // focuss_list
                    ArrayList<RqBusNumList> RqFocus;
                    if (null != details.getCustomerFocusList()) {
                        RqFocus = new ArrayList<RqBusNumList>();
                        for (int u = 0; u < details.getCustomerFocusList().size(); u++) {
                            RqBusNumList info = new RqBusNumList();
                            info.setDictionaryId(details.getCustomerFocusList().get(u).getFocusId());
                            info.setDictionaryName(details.getCustomerFocusList().get(u).getFocusName());
                            info.setSelect(true);
                            RqFocus.add(info);
                        }
                        EmmApplication.RqFocus.clear();
                        EmmApplication.RqFocus.addAll(RqFocus);
                    } else {
                        RqFocus = new ArrayList<RqBusNumList>();
                    }
                    if (null != foucsAdapter) {
                        foucsAdapter.GetDate(RqFocus);
                    } else {
                        foucsAdapter = new FoucsAdapter(CustomerDetailActivity.this, RqFocus);
                        focuss_list.setAdapter(foucsAdapter);
                        foucsAdapter.SetType(9);
                    }

                    // 关注户型
                    ArrayList<GetHouseTypeList.HouseTypeList> HouseTypeList;
                    if (null != details.getHouseTypeList()) {
                        HouseTypeList = details.getHouseTypeList();
                    } else {
                        HouseTypeList = new ArrayList<GetHouseTypeList.HouseTypeList>();
                    }

//                    if (null != attadapter) {
//                        attadapter.SetDateNotify(HouseTypeList);
//                    } else {
//                        attadapter = new AttentionAdapter(CustomerDetailActivity.this, HouseTypeList);
//                        atten_list.setAdapter(attadapter);
//                        attadapter.SetType(1);
//                    }

                    // 需求面积
                    set_m2_1.setText(details.getRqDemandArea());

//                    set_none_allprice.setText(details.getRqBudgetSumPrice());
//
//                    set_unit.setText(details.getRqBudgetPrice());
//
//                    set_paytype.setText(details.getRqPaymentMethod());

                    // 意向组团
                    ArrayList<PremisesList> PremisesList;
                    if (null != details.getPremisesList()) {
                        PremisesList = details.getPremisesList();
                    } else {
                        PremisesList = new ArrayList<PremisesList>();
                    }
//                    if (null != gpadapter) {
//                        gpadapter.SetDateNotify(PremisesList);
//                    } else {
//                        gpadapter = new GroupAdapter(CustomerDetailActivity.this, PremisesList);
//                        group_list.setAdapter(gpadapter);
//                        gpadapter.SetType(1);
//                    }
//
//                    set_lnumber.setText(details.getRqDemandFloor());

                    // 意向房源
                    ArrayList<RoomList> RoomList;
                    if (null != details.getRoomList()) {
                        if (details.getRoomList().size() > 0) {// 底部横线，在列表长度为1以上（包括1）时展示。
                            want_list_lines.setVisibility(View.VISIBLE);
                        } else {
                            want_list_lines.setVisibility(View.GONE);
                        }
                        RoomList = details.getRoomList();
                        if (details.getRoomList().size() > 3) {
                            more_linearlayout.setVisibility(View.VISIBLE);
                        } else {
                            more_linearlayout.setVisibility(View.GONE);
                        }
                    } else {
                        RoomList = new ArrayList<RoomList>();
                        more_linearlayout.setVisibility(View.GONE);
                    }
                    if (null != hgadapter) {
                        hgadapter.SetDateNotify(RoomList);
                    } else {
                        hgadapter = new HousingAdapter(CustomerDetailActivity.this, RoomList);
                        want_list.setAdapter(hgadapter);
                        hgadapter.SetType(1);
                        hgadapter.SetExhibitiontype(1);
                    }

                    // set_td.setText(details.getRqLifeSupport());

                    // set_td2.setText(details.getRqServicesId());

                    // 庭院需求面积
//                    if (null == details.getRqCourtyardArea() || "".equals(details.getRqCourtyardArea())
//                            || "null".equals(details.getRqCourtyardArea())) {
//                        rqCourtyardArea_view.setText("");
//                        unit_area.setVisibility(View.INVISIBLE);
//                    } else {
//                        unit_area.setVisibility(View.VISIBLE);
//                        rqCourtyardArea_view.setText(details.getRqCourtyardArea());
//                    }
//
//                    if (EmmApplication.isNull(details.getRemark())) {
//                        remark_view.setTextColor(getResources().getColor(R.color.text_right));
//                        remark_view.setText(details.getRemark());
//                    } else {
//                        remark_view.setTextColor(getResources().getColor(R.color.edittext_hint_color));
//                        remark_view.setText("暂未备注");
//                    }
//
//                    set_wantpz.setText(details.getRqCourtyardFunction());

                    if (TextUtils.isEmpty(details.getFtContactWay())) { //没有来电
                        llFirstContact.setVisibility(View.GONE);
                    } else {
                        first_do.setText(details.getFtContactWay());
                        first_time.setText(details.getFtContactTime());
                        ftContactContent.setText(details.getFtContactContent());
                    }
                    if (TextUtils.isEmpty(details.getFtContactWay1())) { //没有来访
                        llFirstContact1.setVisibility(View.GONE);
                    } else {
                        tvFirstContactWay.setText(details.getFtContactWay1());
                        tvFirstContacyTime.setText(details.getFtContactTime1());
                        tvFirstContactContent.setText(details.getFtContactContent1());
                    }


//                    set_papers.setText(details.getPeDocumentType());
//
//                    peDocumentNumber.setText(details.getPeDocumentNumber());
//
//                    set_birtch.setText(details.getPeBirth());
//
//                    peAge.setText(details.getPeAge());
//
//                    set_xm.setText(details.getPeAcademicQualifications());
//
//                    peTelephone_view.setText(details.getPeTelephone());
//
//                    peMobile.setText(details.getPeMobile());
//
//                    peWechat_view.setText(details.getPeWechat());
//
//                    peEmail.setText(details.getPeEmail());
//
//                    pePostcode.setText(details.getPePostcode());
//
//                    set_addr.setText(details.getPeDomicilePlace());
//
//                    peContactAddress.setText(EmmApplication.toDBC(details.getPeContactAddress()));

                    set_none1.setText(details.getPeResidence());

                    pePlot_view.setText(EmmApplication.toDBC(details.getPePlot()));

                    peDetailedAddress.setText(EmmApplication.toDBC(details.getPeDetailedAddress()));

                    set_works.setText(details.getPeWorkaround());

                    peWorkaroundAddress_view.setText(EmmApplication.toDBC(details.getPeWorkaroundAddress()));

//                    set_cardtype.setText(details.getPeFrameBrandId());
//
//                    set_priceget.setText(details.getPeHouseholdIncome());

                    // set_intersting.setText(details.getPeHobbyId());

                    // set_happy.setText(details.getPeActivityType());

                    // 家庭情况（列表）
                    ArrayList<FamilyMemberList> FamilyMemberList;
                    if (null != details.getFamilyMemberList()) {
                        for (int i = 0; i < details.getFamilyMemberList().size(); i++) {
                            details.getFamilyMemberList().get(i).setCount("" + (i + 1));
                        }
                        FamilyMemberList = details.getFamilyMemberList();
                    } else {
                        FamilyMemberList = new ArrayList<GetCustomerDetail.FamilyMemberList>();
                    }
//                    if (null != adapter) {
//                        adapter.notifylist(FamilyMemberList);
//                    } else {
//                        adapter = new BirtchdayAdapter(CustomerDetailActivity.this, FamilyMemberList, title_main);
//                        home_list.setAdapter(adapter);
//                        adapter.SetType(1);
//                    }
//
//                    set_mr.setText(details.getPeWeddingDate());
//
//                    reLocalPurchase.setText(details.getReLocalPurchase());
//
//                    reCurrentHoldings.setText(details.getReCurrentHoldings());
//
//                    reResidentialMortgage.setText(details.getReResidentialMortgage());
//
//                    set_htype.setText(details.getReCurrentlyProperty());
//
//                    set_m2s.setText(details.getReCurrentlyArea());
//
//                    set_htype1.setText(details.getReCurrentlyStructure());
//
//                    set_hstacut.setText(details.getReCurrentlyHouse());
//
//                    set_worktime.setText(details.getCoContactTime());
//
//                    set_workltype.setText(details.getCoInformationDays());
//
//                    set_weektime.setText(details.getCoContactWeekend());
//
//                    set_weektype.setText(details.getCoWeekendInformation());

                    if (EmmApplication.isNull(details.getIntentionLevelRemark())) {
                        lvIntentionLevel.setVisibility(View.VISIBLE);
                        vIntentionLv.setVisibility(View.VISIBLE);
                        tvIntentionLevelRemark.setText(details.getIntentionLevelRemark());
                    } else {
                        lvIntentionLevel.setVisibility(View.GONE);
                        vIntentionLv.setVisibility(View.GONE);
                    }

                    getInitData();

//                    InitAdapter(SupportingLifeaceadapter2, 2, SupportingLife_list, SupportingLife_set);

//                    InitAdapter(LifeServiceadapter1, 1, LifeService_list, LifeService_set);

//                    InitAdapter(DailyInformationLearningApproachaceadapter5, 5, DailyInformationLearningApproach_list,
//                            DailyInformationLearningApproach_set);

//                    InitAdapter(HobbyListaceadapter4, 4, HobbyList_list, HobbyList_set);

//                    InitAdapter(ATypeOfActivityThatIsWillingToParticipateaceadapter3, 3,
//                            ATypeOfActivityThatIsWillingToParticipate_list,
//                            ATypeOfActivityThatIsWillingToParticipate_set);

                } else {
                    // EmmApplication.T("加载失败,请稍后再试");
                    EmmApplication.T(details.getErrorMsg().toString());
                    try {
                        Log.v("获取失败", "errorCode:" + details.getErrorCode().toString() + "errorMsg:"
                                + details.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("客户详情，错误信息获取空指针异常", "");
                    }

                }
            }
        });
    }

    ArrayList<RqBusNumList> SupportingLife_set;
    ArrayList<RqBusNumList> LifeService_set;
    ArrayList<RqBusNumList> DailyInformationLearningApproach_set;
    ArrayList<RqBusNumList> HobbyList_set;
    ArrayList<RqBusNumList> ATypeOfActivityThatIsWillingToParticipate_set;

    /**
     * 跟进列表
     */
    GetFollowList getFollow;

    /**
     * <p>
     * <b>Title：</b> 跟进列表
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param customerId
     * @author tangxin
     * @date 2016年12月7日 下午2:09:10
     */
    private void getFollowList(final String customerId) {
        EmmApplication.updateUrl("getFollowList");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("customerId", customerId);
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getFollowList-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                getCustomerDetail(customerId);
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.showDialogForLoading(CustomerDetailActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v(TAG, "content:" + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                getFollow = JSONObject.parseObject(resData.toString(), GetFollowList.class);
                if ("1".equals(getFollow.getResult())) {
                    Log.v("获取成功", "");
                    if (null != getFollow) {
                        genjinadapter = new FollowUpAdapter(CustomerDetailActivity.this, getFollow, 1);
                        genjin_list.setAdapter(genjinadapter);
                    }
                } else {
                    EmmApplication.T(getFollow.getErrorMsg().toString());
                    try {
                        Log.v("获取失败", "errorCode:" + getFollow.getErrorCode().toString() + "errorMsg:"
                                + getFollow.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("客户详情，错误信息获取空指针异常", "");
                    }
                }
                getCustomerDetail(customerId);
            }
        });
    }

    private void queryProjectQuestionnaireList() {
        EmmApplication.updateUrl("queryProjectQuestionnaireList");
        Map<String, String> map = new HashMap<>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("projectId", EmmApplication.getProjectID());
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.w("login___>post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {

            @Override
            public void onFinish() {
                super.onFinish();
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);

                if (content == null) {
                    Log.v(TAG, "数据为空");
                    return;
                }
                Log.v("登陆请求成功", "userId : " + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "登陆信息返回值为空");
                    return;
                }
                queryProjectQuestionnaireList queryProjectQuestionnaireList = JSONObject.parseObject(resData.toString(), queryProjectQuestionnaireList.class);
                if ("1".equals(queryProjectQuestionnaireList.getResult())) {
                    if (null != queryProjectQuestionnaireList.getAppProjectQuestionnaireList() && queryProjectQuestionnaireList.getAppProjectQuestionnaireList().size() > 0) {
                        lvInvestigation.setVisibility(View.VISIBLE);
                        investigationAdapter.setInvestigationAdapter(queryProjectQuestionnaireList.getAppProjectQuestionnaireList());
                    }
                } else {
                    try {
                        EmmApplication.showTips(queryProjectQuestionnaireList.getErrorMsg());
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    private void getTagList() {
        EmmApplication.updateUrl("getTagList");
        Map<String, String> map = new HashMap<>();
        map.put("version", "");
        map.put("token", "");
        map.put("sign", "");
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.w("login___>post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFinish() {
                super.onFinish();
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);

                if (content == null) {
                    Log.v(TAG, "数据为空");
                    return;
                }
                Log.v("登陆请求成功", "userId : " + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "登陆信息返回值为空");
                    return;
                }
                GetTagListBean getTagListBean = JSONObject.parseObject(resData.toString(), GetTagListBean.class);
                if ("1".equals(getTagListBean.getResult())) {
                    if (null != getTagListBean.getTagList() && getTagListBean.getTagList().size() > 0) {
                        lvInvestigation.setVisibility(View.VISIBLE);
                        tagListAdapter.setTagListBean(getTagListBean.getTagList());
                    }
                } else {
                    try {
                        EmmApplication.showTips(getTagListBean.getResultMsg());
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }

}